package cn.zcy.controller.i18n;

import cn.zcy.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.Valid;

@Controller
public class UserController {

    @PostMapping("/login")
    public String login(@Valid User user, BindingResult bindingResult, Model model){

        if (bindingResult.hasErrors()){
            return "i18n";
        }
        if (!user.getEmail().equals("123@qq.com")&& !user.getPassword().equals("123456")){
            model.addAttribute("errMsg","用户名或密码错");
            return "i18n";
        }
        return "admin";
    }
}
